package com.pan.excep;


import com.pan.entity.Result;
import com.pan.excep.error.ServiceException;
import com.pan.tools.ConvertObject;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result serviceHandler(ServiceException serviceException){
        Result result = (Result) ConvertObject
                .convertObject(Result.class,serviceException);
        return result;
    }


}
